#ifndef _H_C_ASIO_SERVICE_H_
#define _H_C_ASIO_SERVICE_H_

#include "../typedefine.h"
#include <functional>
#include <memory>

namespace TB
{
	class CNetServiceImpl;
	class CCoroutine;

	class CNetService
	{
		NON_COPYABLE(CNetService)
		NON_MOVEABLE(CNetService)

	private:
		CNetService();
	public:
		~CNetService();
		inline static std::shared_ptr<CNetService> NewNetService() { return std::shared_ptr<CNetService>(new CNetService()); }
		bool Init(const std::weak_ptr<CCoroutine>& poCoroutine, const std::function<void(INT32)>& rcbOnPollError = nullptr);
		inline CNetServiceImpl* GetImpl() { return m_poImpl.get(); }
		inline const CNetServiceImpl* GetImpl() const { return m_poImpl.get(); }
		std::weak_ptr<CCoroutine>& GetCoroutine();
		const std::weak_ptr<CCoroutine>& GetCoroutine() const;
		void Close();

	private:
		std::shared_ptr<CNetServiceImpl> m_poImpl;
	};
}

#endif
